home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_2.arc / PMDEV1.ARC / PMAUXNT.C < prev    next >
Text File  |  1988-12-03  |  3KB  |  104 lines

  1. /*
  2.  * Initialization module for PMAUX
  3.  *
  4.  * Written by William S. Hall
  5.  * 3665  Benton Street, #66
  6.  * Santa Clara, CA 95051
  7.  *
  8.  */
  9.  
  10. #define INCL_PM
  11. #include <os2.h>
  12. #include <stddef.h>
  13. #include <ttycls.h>
  14. #include "pmaux.h"
  15.  
  16. BOOL FAR InitProgram(int argc, char *argv[])
  17. {
  18.  
  19.     char szTitle[50];
  20.     ULONG ctldata;
  21.  
  22.   /* get anchor block handle and message queue handles */
  23.     if ((hAB = WinInitialize(NULL)) == NULL)
  24.     return FALSE;
  25.  
  26.     if ((hmqMsgQ = WinCreateMsgQueue(hAB,0)) == NULL)
  27.         return FALSE;
  28.  
  29.   /* get handle to the local heap so we can use it later */
  30.     if ((hHeap = WinCreateHeap(0, 0, 0, 0, 0, 0)) == NULL)
  31.     return FALSE;
  32.  
  33.   /* This string is needed to register the Window */
  34.     WinLoadString(hAB,NULL, IDS_APPNAME, sizeof(szAppName), (PSZ)szAppName);
  35.  
  36.   /* register window */
  37.     if (!WinRegisterClass(hAB,             /* anchor block handle */
  38.               (PCH)szAppName,     /* class name */
  39.               (PFNWP)MainWndProc,    /* window procedure for class */
  40.               CS_SIZEREDRAW,       /* class styles */
  41.               0))            /* no extra data needed */
  42.     return FALSE;
  43.  
  44.   /* This string is needed to create the frame window */
  45.     WinLoadString(hAB, NULL, IDS_TITLE, sizeof(szTitle), (PSZ)szTitle);
  46.  
  47.     ctldata = FCF_STANDARD;
  48.  
  49.   /* create window */
  50.     hwndFrame = WinCreateStdWindow(HWND_DESKTOP,    /* parent */
  51.                    WS_VISIBLE,
  52.                    &ctldata,
  53.                                    (PCH)szAppName,    /* class */
  54.                                    (PCH)szTitle,    /* window title */
  55.                                    0L,            /*default client style*/
  56.                                    (HMODULE)NULL,    /* resources in .EXE */
  57.                                    ID_RESOURCE,
  58.                                    (HWND FAR *)&MWnd.hWnd);
  59.                             /* handle to client */
  60.  
  61.   /* fail if creation of either window or video buffer fails */
  62.     if ((hwndFrame == NULL) || (MWnd.pVidBuf == NULL))
  63.     return FALSE;
  64.  
  65.   /* show the window */
  66.     WinShowWindow(hwndFrame, TRUE);
  67.  
  68.   /* set the handle into OS2.ini */
  69.     if (!SetOS2Ini(MWnd.hWnd))
  70.         return FALSE;
  71.  
  72.     return TRUE;
  73. }
  74.  
  75. /* called when client is created */
  76. void FAR WndCreate(HWND hWnd)
  77. {
  78.  
  79.     FONTMETRICS FM;
  80.     HPS hPS;
  81.     short width, height, cwidth, cheight;
  82.  
  83.   /* get the size of an icon */
  84.     xIconsize = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
  85.     yIconsize = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
  86.  
  87.   /* load the icon string */
  88.     WinLoadString(hAB, NULL, IDS_ICON, (USHORT)sizeof(szIcon), (PSZ)szIcon);
  89.  
  90.   /* get the system font character metrics */
  91.     hPS = WinGetPS(hWnd);
  92.     GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &FM);
  93.     cwidth = (short)(FM.lMaxBaselineExt + FM.lExternalLeading);
  94.     cheight = (short)FM.lAveCharWidth;
  95.     WinReleasePS (hPS);
  96.  
  97.   /* get other parameters */
  98.     width = (SHORT)WinQuerySysValue(HWND_DESKTOP, SV_CXFULLSCREEN);
  99.     height = (SHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYFULLSCREEN);
  100.  
  101.   /* create the video buffer with the following parameters */
  102.     InitTTYWindow(&MWnd,0,0,width,height,cwidth,cheight,FALSE,TRUE,TRUE,0xff);
  103. }
  104.